import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yp/config/index.dart';
import 'package:yp/router.dart';
import 'package:yp/widgets/button_widget.dart';
import 'package:yp/widgets/index.dart';
import 'package:yp/widgets/navigation_bar.dart';
import 'package:yp/widgets/shop.dart';

/// 售后/退款
class AfterMarket extends StatefulWidget {
  const AfterMarket({Key key}) : super(key: key);

  @override
  _AfterMarketState createState() => _AfterMarketState();
}

class _AfterMarketState extends State<AfterMarket>
    with SingleTickerProviderStateMixin {
  AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(vsync: this);
  }

  @override
  void dispose() {
    super.dispose();
    _controller.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: YPNavigationBar( '售后/退款'),
      body: ListView.separated(
          itemBuilder: (context, index) {
            return _goodsInfo();
          },
          separatorBuilder: (context, index) {
            return YpLine(
                height: 20, thickness: 20, color: EsColors.BackGroundSecondary);
          },
          itemCount: 10),
      backgroundColor: EsColors.White,
    );
  }

  /// 店铺&商品信息
  Widget _goodsInfo() {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: () {
        /// 查看退款详情
        Get.toNamed(RouteConfig.refundProgress);
      },
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          ShopName(
            '嘉定安亭嘉亭荟店',
            orderState: '审核中',
          ),
          YpLine(),
          // 单个商品
          _goodsItem(),
          // 多个商品 打开
          // ListView.separated(
          //     padding: EdgeInsets.zero,
          //     physics: NeverScrollableScrollPhysics(),
          //     shrinkWrap: true,
          //     itemBuilder: (context, index) {
          //       return _goodsItem();
          //     },
          //     separatorBuilder: (context, index) {
          //       return YpLine(indent: 12);
          //     },
          //     itemCount: 1),
          YpLine(),
          Padding(
            padding: const EdgeInsets.only(left: 12, top: 12, bottom: 12),
            child: Text(
              '仅退款',
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(
                  color: EsColors.TitleSecondary,
                  fontSize: EsSizes.SM,
                  fontWeight: EsFontWeights.Normal),
            ),
          ),
        ],
      ),
    );
  }

  /// 商品条目
  Widget _goodsItem() {
    return Padding(
      padding: const EdgeInsets.only(top: 12, left: 12, right: 12, bottom: 10),
      child: Row(children: [
        CachedImage(
            width: 50,
            height: 50,
            margin: EdgeInsets.fromLTRB(0, 10, 8, 12),
            scale: BoxFit.cover,
            path:
                'http://imgservice.suning.cn/uimg1/b2c/image/LbK15Wx6ONCA2R1lpJXkOg.jpg_800w_800h_4e'),
        SizedBox(width: 6),
        Expanded(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: [
              Text(
                '方太（FOTILE）CXW-258-JC7...',
                maxLines: 1,
                overflow: TextOverflow.ellipsis,
                style: TextStyle(
                    color: EsColors.TitleSecondary,
                    fontSize: EsSizes.SM,
                    fontWeight: EsFontWeights.Normal),
              ),
              Padding(
                padding: const EdgeInsets.only(top: 12, bottom: 10),
                child: Text(
                  '颜色：白色  数量：1件',
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                  style: TextStyle(
                      color: EsColors.Content,
                      fontSize: EsSizes.XS,
                      fontWeight: EsFontWeights.Normal),
                ),
              )
            ],
          ),
        ),
      ]),
    );
  }
}
